﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Template.Core.Utils.JWT;

namespace Template.Core.Controllers
{
    /// <summary>
    /// 登录控制器
    /// </summary>
    [AllowAnonymous]
    [Route("[controller]")]
    public class LoginController : Controller
    {
        /// <summary>
        /// NLog注入，日志开启
        /// </summary>
        private readonly ILogger<LoginController> _logger;

        public LoginController(ILogger<LoginController> logger)
        {
            _logger = logger;
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Route("[action]")]
        public IActionResult login(string username,string pass)
        {
            Token token = new Token()
            {
                Uid = 1,
                Role = "Admin"
            };
            string tokenStr = JWTHelper.CreateJwt(token);
            return Json(tokenStr);
        }
    }
}
